﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Game.EnemyScripts
{
    class Laser:IEnemy
    {
        private Vector2 _position;
        private readonly Texture2D _texture;
        private float _rotation;

        public Laser(Vector2 position, Texture2D texture, float rotation)
        {
            _position = position;
            _texture = texture;
            _rotation = rotation;
        }
        
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(_texture, _position, null, Color.White, _rotation, new Vector2(_texture.Width / 2f, _texture.Height / 2f), 1, SpriteEffects.None, 0);
        }

        public void Update(GameTime gameTime)
        {
            float time = gameTime.ElapsedGameTime.Milliseconds/3f;
            _position.X += (float)Math.Cos(_rotation) * time;
            _position.Y += (float)Math.Sin(_rotation) * time;
        }

        public Rectangle GetBoundingRect()
        {
            var rect = new Rectangle((int)_position.X, (int)_position.Y, _texture.Width, _texture.Height);
            return rect;
        }
    }
}
